package com.dingli.controller;

import com.dingli.framework.entity.News;
import com.dingli.framework.util.Response;
import com.dingli.service.INewsService;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@CrossOrigin("*")
@RestController
@RequestMapping("/news")
@Api(tags = "文旅政策")
public class NewsController {

    @Autowired
    private INewsService iNewsService;

    @GetMapping("/NEWS_LIST")
    @ApiOperation("文旅信息列表查询")
    public Response<PageInfo<News>> NEWS_LIST(@ApiParam("查询条件")
                                             @RequestParam(required = false) String search,
                                           @ApiParam("页码") @RequestParam(required = false) Integer pageNum,
                                           @ApiParam("页面大小")
                                             @RequestParam(required = false) Integer pageSize) {
        return iNewsService.NEWS_LIST(search, pageNum, pageSize);
    }

    @PostMapping("/NEWS_insert")
    @ApiOperation("文旅信息新增")
    public Object NWinsert(@ApiParam("文旅信息") @RequestBody News news) {
        return iNewsService.NEWS_insert(news);
    }

    @GetMapping("/NEWS_selectById")
    @ApiOperation("文旅信息详情查看")
    public Response<News> NEWS_selectById(@ApiParam("文旅ID") @RequestParam Long nID) {
        return iNewsService.NEWS_selectById(nID);
    }

    @PostMapping("/NEWS_updateById")
    @ApiOperation("文旅信息修改")
    public Response<Object> NEWS_updateById(@ApiParam("修改的文旅信息") @RequestBody News news) {

        return iNewsService.NEWS_updateById(news);
    }

    @GetMapping("/NEWS_deleteById")
    @ApiOperation("文旅信息删除")
    public Response<Object> NEWS_deleteById(@ApiParam("文旅ID") @RequestParam Long nID) {
        return iNewsService.NEWS_deleteById(nID);
    }
}
